/**
 *  Copyright (c) 2014 The xmlepf project.  All rights reserved.
 *
 *  This file is part of xmlepf (Event Driven Testing Framework).
 *
 *  xmlepf is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  xmlepf is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with xmlepf.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  This software consists of voluntary contributions made by many
 *  individuals.  For exact contribution history, see the revision
 *  history and logs, available at http://code.google.com/p/xmlepf.
 */
package org.xmlepf.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;

/**
 *
 *
 */
public class DateUtils {

    private static final String defaultDateFormatting = "yyyy-MM-dd'T'HH:mm:ss";

    public static String getDate() {
        return getDate(defaultDateFormatting);
    }

    public static String getDate(String dateFormatting) {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatting);
        return simpleDateFormat.format(calendar.getTime());
    }

    public static String getDateMicrosecond() {
        return getDateMicrosecond(defaultDateFormatting);
    }

    public static String getDateMicrosecond(String dateFormatting) {
        StringBuilder date = new StringBuilder(getDate(dateFormatting));
        date.append(":");
        date.append(TimeUnit.MICROSECONDS.toString());
        return date.toString();
    }
}
